package com.util.thread;

import cn.hutool.core.thread.ConcurrencyTester;
import cn.hutool.core.thread.SyncFinisher;
import cn.hutool.core.thread.ThreadUtil;
import lombok.SneakyThrows;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * @author xin.ding
 * @date 2020/10/31 10:11
 */
public class ThreadPool {
//    ExecutorService pool = Executors.newCachedThreadPool();
//    ThreadPoolExecutor.DiscardPolicy();

    public static void main(String[] args) {
//        Callable callable = new Callable() {
//            @Override
//            public Object call() throws Exception {
//                Thread.sleep(100);
//                System.out.println(Thread.currentThread().getId() + " sleep finished");
//                return Thread.currentThread().getId() + " sleep finished";
//            }
//        };
//
//        ExecutorService executorService = ThreadUtil.newExecutor(5);
//        ThreadUtil.newExecutor()
//        executorService.submit(callable);

        ConcurrencyTester c = new ConcurrencyTester(1);
        c.test(new Runnable() {
            @SneakyThrows
            @Override
            public void run() {
                Thread.sleep(1000);
                System.out.println("thread " + Thread.currentThread().getName());
            }
        });
        System.out.println(c.getInterval());


    }
}
